/*
 * @Author: gonghairun
 * @Date: 2022-02-22 13:50:43
 * @LastEditors: zhangyongbing
 * @LastEditTime: 2022-05-13 11:40:57
 * @Description:
 */
import { Service } from "../../network/http.js"

import { ServiceName } from "../../network/http.js"
import axios from "axios"
const select = {
	state: {
		companyList: JSON.parse(window.sessionStorage.getItem("companyList")) || [], //作业公司
		keyList: JSON.parse(window.sessionStorage.getItem("keyList")) || {}, //字典数据
		processList: JSON.parse(window.sessionStorage.getItem("processList")) || {}, //字典数据
		workTimeList: JSON.parse(window.sessionStorage.getItem("workTimeList")) || {}, // 班次
		listoperationList: JSON.parse(window.sessionStorage.getItem("listoperationList")) || {}, // 操作工艺
		filedList: JSON.parse(window.sessionStorage.getItem("filedList")) || {}, // 场地

	},
	mutations: {
		/**
		 * @Author: gonghairun
		 * @description: 作业公司
		 * @param {*}
		 * @return {*}
		 */
		setCompanyList(state, data) {
			state.companyList = data
			console.log(data)
			window.sessionStorage.setItem("companyList", JSON.stringify(data))
		},
		/**
		 * @Author: gonghairun
		 * @description: 字典表
		 * @param {*}
		 * @return {*}
		 */
		setKeyList(state, data) {
			state.keyList = data
			window.sessionStorage.setItem("keyList", JSON.stringify(data))
		},
		/**
		 * @Author: gonghairun
		 * @description: 字典表
		 * @param {*}
		 * @return {*}
		 */
		setProcessList(state, data) {
			state.processList = data
			window.sessionStorage.setItem("processList", JSON.stringify(data))
		},
		/**
		 * @Author: gonghairun
		 * @description: 班次
		 * @param {*}
		 * @return {*}
		 */
		 setWorkTimeList(state, data) {
			state.workTimeList = data
			window.sessionStorage.setItem("workTimeList", JSON.stringify(data))
		},
		 /**
		 * @Author: gonghairun
		 * @description: 操作工艺
		 * @param {*}
		 * @return {*}
		 */
		  setListoperationList(state, data) {
			state.listoperationList = data
			window.sessionStorage.setItem("listoperationList", JSON.stringify(data))
		},
		/**
		 * @Author: gonghairun
		 * @description: 场地数据
		 * @param {*}
		 * @return {*}
		 */
		setFiledList(state, data) {
			state.filedList = data
			window.sessionStorage.setItem("filedList", JSON.stringify(data))
		},

	},
	actions: {
		/**
		 * @Author: gonghairun
		 * @description: 基础数据
		 * @param {*} commit
		 * @return {*}
		 */
		getBaseData({ commit }) {
			/* 获取基础数据 */
			/*function getKeyList() {
				return Service.get(
					`/${ServiceName}/api/external/community/public/list_all_dict?dicttype=`
					+ `TRAIN_TYPE,WORK_AREA,CARGO_FORM,METER_WEIGHTSORT,CARGO_INHATCH,TOW_WORK_TYPE,TRADE_TYPE,INOUT_TYPE,`
					+ `STATUS,HANDOVER_TYPE,SPEC,PACKAGE,MARK,DRINK_TYPE,CARGOCLASS,ship_nation,ship_kind,`
					+`ship_type,crane_type,LOAD_FLAG,DATA_STATUS,NATION`
				)
			}*/
			/* 获取操作过程 */
			function getProcess() {
				return Service.get(`/${ServiceName}/api/external/protected/listprocess?parentid=0`)
			}
			/* 获取公司数据 */
			function getCompany() {
				return Service.get(`/${ServiceName}/api/external/publics/listworkcompany`)
			}
			/* 获取班次数据 */
			function getWorkTime() {
				return Service.get(`/${ServiceName}/api/external/protected/listschedulebyareacode`)
			}
			/* 获取操作工艺数据 */
			function getListoperation() {
				return Service.get(`/${ServiceName}/api/external/protected/listoperation`)
			}
			/* 获取场地数据 */
			function getFiled() {
				return Service.get(`/${ServiceName}/api/external/protected/liststorehousebycompanycode`)
			}

			// axios.all([getProcess(), getCompany(),getWorkTime(),getListoperation(),getFiled()]).then(
			// 	axios.spread(function (key, process, company,workTime,listoperation,filed) {
			// 		console.log(key, "key")
			// 		let keyData = key.data.data
			// 		let processData = process.data.data
			// 		let companyData = company.data.data
			// 		let workTimeData = workTime.data.data
			// 		let listoperationData = listoperation.data.data
			// 		let filedData = filed.data.data
			// 		commit("setKeyList", keyData)
			// 		commit("setCompanyList", companyData)
			// 		commit("setProcessList", processData)
			// 		commit("setWorkTimeList", workTimeData)
			// 		commit("setListoperationList", listoperationData)
			// 		commit("setFiledList", filedData)
			// 	})
			// )
		},
	},
}

export default select
